package enums;

/**
 * 大陆（洲）枚举
 */
public enum Continent {
    AF("AF", "Africa", "非洲"),
    AN("AN", "Antarctica", "南极洲"),
    AS("AS", "Asia", "亚洲"),
    EU("EU", "Europe", "欧洲"),
    NA("NA", "North America", "北美洲"),
    OC("OC", "Oceania", "大洋洲"),
    SA("SA", "South America", "南美洲");

    private final String code;
    private final String nameEn;
    private final String nameZh;

    Continent(String code, String nameEn, String nameZh) {
        this.code = code;
        this.nameEn = nameEn;
        this.nameZh = nameZh;
    }

    public String getCode() {
        return code;
    }

    public String getNameEn() {
        return nameEn;
    }

    public String getNameZh() {
        return nameZh;
    }

    /**
     * 根据大陆代码获取枚举（忽略大小写）
     */
    public static Continent of(String code) {
        if (code == null || code.isEmpty()) {
            return null;
        }
        for (Continent continent : values()) {
            if (continent.code.equalsIgnoreCase(code.trim())) {
                return continent;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return code + " - " + nameZh + " (" + nameEn + ")";
    }
}